/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef DEVICES_FLASH_H
#define DEVICES_FLASH_H


/* Includes ------------------------------------------------------------------*/
#include "stm32f4xx_hal.h"
#include "stdint.h"
#include "string.h"

/* Exported constants --------------------------------------------------------*/
/* ============ Lidar flash corss ============ */
/* Address */
#define LID_E22_ModuleAddress_Ads 					0x08060000 		//2B
#define LID_E22_FrequencyChannel_Ads 				0x08060002		//2B
#define LID_Algorithm_TwoLineSpacing_M_Ads 	0x08060004 		//2B

/* Value */
#define LID_E22_ModuleAddress 						390
#define LID_E22_FrequencyChannel 					19
#define LID_Algorithm_TwoLineSpacing 				20

/* Version */
#define Lidar_Version "+VER:MX01S,1.0.0"

/* ============ Receiver flash corss ============ */
/* Address */
#define REC_E22_ModuleAddress_Ads 					0x08070000		//2B
#define REC_E22_FrequencyChannel_Ads 				0x08070002		//2B 

/* Value */
#define REC_E22_ModuleAddress						512
#define REC_E22_FrequencyChannel					25

/* Version */
#define Receive_Version "\r\n+VERSIONR:\"MX01S\",\"1.0\"\r\n"

/* Exported macros -----------------------------------------------------------*/
#define FlashFnc_GroundInit \
{ \
	&Flash_EraseSector, \
	&Flash_LID_AdministratorWrite, \
	&Flash_REC_AdministratorWrite, \
	&Flash_REC_AdminstratorWrite_F,\
	&Flash_LID_REC_CustomRead, \
	&Flash_LID_REC_CustomSync, \
} \


/* Exported types ------------------------------------------------------------*/
typedef struct
{
	void(*Flash_EraseSector)(FLASH_EraseInitTypeDef* Erase);
	void(*Flash_LID_AdministratorWrite)(void);
	void(*Flash_REC_AdministratorWrite)(void);
	void(*Flash_REC_AdminstratorWrite_F)(int cha,int addr);
	void(*Flash_LID_REC_CustomRead)(void);
	void(*Flash_LID_REC_CustomSync)(void);
}Flash_Fuc;



typedef struct
{
	/* Lidar Data */
	uint16_t 	LID_E22ModuleAddress;
	uint8_t 	LID_E22FrequencyChannel;
	uint16_t 	LID_AlgorithmTwoLineSpacing;
	
	/* Receiver Data */
	uint16_t 	REC_E22ModuleAddress;
	uint8_t 	REC_E22FrequencyChannel;
	
}Flash_Sync_Data_t;


/* Exported variables --------------------------------------------------------*/
extern Flash_Fuc Flash_Function;
extern FLASH_EraseInitTypeDef Erase;
extern uint32_t SectorError;
extern Flash_Sync_Data_t Flash_SyncData;

/* End -----------------------------------------------------------------------*/
#endif
